using UnityEngine;
using Delta2DGame.Base;

namespace Delta2DGame.State
{
    /// <summary>
    /// 待机状态
    /// </summary>
    public class IdleState : PlayerState
{
    public IdleState(PlayerStateMachine stateMachine, PlayerController player, string animBoolName) : base(stateMachine, player, animBoolName)
    {}

    // public override void Enter()
    // {
    //     base.Enter();
    //     // 停止角色移动
    //     player.StopMovement();
    // }

    public override void Update()
    {
        base.Update();

        // 检测移动输入，切换到跑步状态
        if (Mathf.Abs(player.GetMoveInput().x) > 0.1f || Mathf.Abs(player.GetMoveInput().y) > 0.1f)
        {
            stateMachine.SwitchState(stateMachine.runState);
        }
        // 检测跳跃输入，切换到跳跃状态
        else if (player.IsJumpPressed())
        {
            stateMachine.SwitchState(stateMachine.jumpState);
        }
    }
}
}